#import "OmSendGiftView.h"
#import "GiftModel.h"
#import "GiftView.h"
#import "GiftLogic.h"
#define AutoSize(px) ((kScreenHeight > kScreenWidth) ? ([UIScreen mainScreen].bounds.size.width/750)*(px) : ([UIScreen mainScreen].bounds.size.height/750)*(px))
@interface OmSendGiftView () <GiftViewDelegate>
@property(nonatomic, strong) UIButton *maskView;
@property(nonatomic, strong) GiftView *giftview;
@property(nonatomic, strong) NSArray *giftList;
@property(nonatomic, strong)  GiftLogic *giftLogic;
@end
@implementation OmSendGiftView
- (instancetype)initWithToUid:(NSString *)touid {
    self = [super init];
    if (self) {
        _touid = touid;
    }
    return self;
}
- (void)configSelf {
}
- (void)allocateComponents {
    _maskView = [[UIButton alloc] init];
    self.maskView.fp_addTargetActionForControlEvents(self, @selector(maskViewTap), UIControlEventTouchUpInside);
    [self addSubview:_maskView];
    self.giftLogic = [GiftLogic new];
    [self.giftLogic getGiftListHookData:^(NSArray *giftList) {
        self.giftList = giftList;
        self.giftview = [[GiftView alloc]initWithShareViewToView:self.maskView AndGift:self.giftList];
        self.giftview.delegate = self;
        [self.maskView addSubview:self.giftview];
    }];
}
- (void)layoutComponents {
    [self.maskView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.equalTo(self);
    }];
}
- (void)maskViewTap {
    self.hidden = YES;
}
-(void)giftSendClickWithInfo:(GiftModel *)model AndNumber:(NSInteger)number {
    if(number == 0) {
        [[HUDHelper sharedInstance] tipMessage:ASLocalizedString(@"需要选择发送礼物数量")];
        return;
    }
    self.giftLogic.touid = self.touid;
    [self.giftLogic sendGiftWith:model AndNumber:number Hook:^(BOOL sendSuccess, NSString *error, TIMMessage *message) {
        [self maskViewTap];
        [MBProgressHUD showTopTipMessage:error];
        if(sendSuccess) {
        }
    }];
}
@end
